<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>LAB1 - alternative for http://www.childofthemachine.com/blog/2009/08/zend_navigation-tricks-true-tab-navigation-with-sub-menus-part-1/</title>
<style type="text/css">
	* {
		color: #333;
		font-weight: normal;
	}
	body {
		width:1000px;
		margin: 0px auto;
		font-family: Georgia;
	}
	a {
		color: #900;
		text-decoration: none;
	}
	a:hover {
		color: #600;
		text-decoration: underline;
	}
	h1 {
		/*font-family: Tahoma, Arial, helvetica, clean, sans-serif;*/
		margin: 0px 0px 15px;
		padding: 0px 0px 15px;
		border-bottom: solid 1px #333;
		font-size: 50px;
	}
	h2 {
		margin: 40px 0px 10px;
	}
	h3 {
		margin: 10px 0px;
	}
	pre {
		background-color: #eee;
		border: dotted 1px #ccc;
		padding: 15px;
		display: block;
		position: relative;
		overflow: auto; 
	}
	.preview {
		display: block;
		position: relative;
		width: 490px;
		float: left;
		clear: both;
		margin: 0px 10px 10px 0px;
	}
	.preview .container {
		border: dotted 1px #ccc;
		padding: 2px;
	} 
	.html {
		display: block;
		position: relative;
		width: 500px;
		float: left;
		clear: right;
		margin: 0px 0px 10px 0px;
	}
	.code {
		display: block;
		position: relative;
		clear: both;
		width: 1000px;
		margin: 0px 0px 10px 0px;
	}
	#navigation_preview {
		width: 1000px;
	}
	#navigation_preview pre {
		height: 200px;
		overflow: auto;
	}
	.note {
		border: dotted 1px #ccc;
		padding: 15px;
		background-color: #FEE;
		
	}
</style>
<link href="<?php echo $this->url(array('action'=>'example1.css', 'controller'=>'style'))?>" media="screen" rel="stylesheet" type="text/css" /> 
</head>
<body>
<h1>LAB#1 - searching alternatives for <a href="http://www.childofthemachine.com/blog/2009/08/zend_navigation-tricks-true-tab-navigation-with-sub-menus-part-1/">Zend_Navigation Tricks: True tab navigation with sub menus</a></h1>
<p class="note">This page is interactive, previews are working. So, pressing menu item in the first example will update other examples; clicking on submenu item, will navigate deeper in navigation hierarchy. If you do not see submenu or breadcrumb try <a href="<?php echo $this->url(array('action'=>'networking', 'controller'=>'index'))?>">"Computers" -> "Networking"</a> I had used (almost) the same <a href="#nav_struct">navigation structure</a> like Grant in his tutorial.</p>
<div id="example_1" class="example">
	<h2>EXAMPLE 1 - Building tabs</h2>
	<div class="preview">
		<h3>Preview</h3>
		<p>These tabs looks exactly the same like in tutorial and are created by using default Zend_Navigation functionality. I had accomplished this by changing structure of navigation and making "Home" of the same level like "Computers", "Measures" and "Calculators". As in ZF 1.9 there were some compatibility breaking changes in this component, there are chances that it was not possible in ZF 1.8.</p>
		<div class="container">
<?php
    echo $this->navigation()->menu()->setMaxDepth(0); 
?>
		</div>
	</div>
	<div class="html">
		<h3>Generated HTML</h3>
		<pre>
<?php
    echo htmlentities($this->navigation()->menu()->setMaxDepth(0)); 
?>
		</pre>
	</div>
	<div class="code">
		<h3>Code</h3>
		<pre>
<?php 
        echo htmlentities('echo $this->navigation()->menu()->setMaxDepth(0);');
?>
		</pre>
	</div>
</div>
<div id="example_2" class="example">
	<h2>EXAMPLE 2 - Building submenu</h2>
	<div class="preview">
		<h3>Preview</h3>
		<p>Grant was correct saying that it is not possible to render multiple level submenus with standard functionality. The first impression was misleading and I expected much more from configuration options available for menu generation. In my opinion it is a serious limitation of this component.</p>
		<div class="container">
<?php
    $mindepth = 1;
    $maxdepth = 10;
    $onlyactive = true;
    $renderparents = false;
    echo $this->navigation()->menu()
                ->setMaxDepth($maxdepth)
                ->setMinDepth($mindepth)
                ->setOnlyActiveBranch($onlyactive)
                ->setRenderParents($renderparents); 
?>
		</div>
	</div>
	<div class="html">
		<h3>Generated HTML</h3>
		<pre>
<?php
    echo htmlentities($this->navigation()->menu()
                ->setMaxDepth($maxdepth)
                ->setMinDepth($mindepth)
                ->setOnlyActiveBranch($onlyactive)
                ->setRenderParents($renderparents)); 
?>
		</pre>
	</div>
	<div class="code">
		<h3>Code</h3>
		<pre>
<?php 
        echo htmlentities('echo $this->navigation()->menu()
            ->setMaxDepth(' . $maxdepth . ')
            ->setMinDepth(' . $mindepth . ')
            ->setOnlyActiveBranch(true)
            ->setRenderParents(false);');
?>
		</pre>
	</div>
</div>
<div id="example_3" class="example">
	<h2>EXAMPLE 3 - Building breadcrumbs</h2>
	<div class="preview">
		<h3>Preview</h3>
		<p>As in ZF 1.9 there were some compatibility breaking changes in this component, there are chances that it was not possible in ZF 1.8.</p>
		<div class="container">
<?php
     echo $this->navigation()
             ->breadcrumbs()
             ->setMaxDepth($maxdepth)
             ->setMinDepth(0)
             ->setLinkLast(true);
?>
		</div>
	</div>
	<div class="html">
		<h3>Generated HTML</h3>
		<pre>
<?php
    echo htmlentities($this->navigation()
             ->breadcrumbs()
             ->setMaxDepth($maxdepth)
             ->setMinDepth(1)
             ->setLinkLast(true)); 
?>
		</pre>
	</div>
	<div class="code">
		<h3>Code</h3>
		<pre>
<?php 
        echo htmlentities('$this->navigation()
             ->breadcrumbs()
             ->setMaxDepth(' . $maxdepth . ')
             ->setMinDepth(1)
             ->setLinkLast(true);');
?>
		</pre>
	</div>
</div>
<div id="navigation_preview">
	<h2><a name="nav_struct"></a>Navigation structure used</h2>
	<pre>
<?php
    
//    $file_handler = fopen(APPLICATION_PATH . '/configs/navigation.xml', 'r');  
//    $contents = fread($file_handler, filesize(APPLICATION_PATH . '/configs/navigation.xml'));  
//    fclose($file_handler);

    $contents = '<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<navigation>
		<home>
			<label>Home</label>
			<controller>index</controller>
			<action>index</action>
		</home>
		<computers>
			<label>Computers</label>
			<controller>index</controller>
			<action>computers</action>
			<pages>
				<networking>
					<label>Networking</label>
					<controller>index</controller>
					<action>networking</action>
					<pages>
						<ipaddress>
							<label>IP Address</label>
							<controller>index</controller>
							<action>ipaddress</action>
						</ipaddress>
						<ping>
							<label>Ping</label>
							<controller>index</controller>
							<action>ping</action>
						</ping>
						<dnsquery>
							<label>DNS query</label>
							<controller>index</controller>
							<action>dnsquery</action>
						</dnsquery>
						<httpredirect>
							<label>HTTP redirect</label>
							<controller>index</controller>
							<action>httpredirect</action>
						</httpredirect>
					</pages>
				</networking>
				<security>
					<label>Security</label>
					<controller>index</controller>
					<action>security</action>
					<pages>
						<passwordgen>
							<label>Password generator</label>
							<controller>index</controller>
							<action>passwordgen</action>
						</passwordgen>
						<hashgen>
							<label>Hash generator</label>
							<controller>index</controller>
							<action>hashgen</action>
						</hashgen>
					</pages>
				</security>
			</pages>
		</computers>
		<measures>
			<label>Measures</label>
			<controller>index</controller>
			<action>measures</action>
			<pages>
				<area>
					<label>Area</label>
					<controller>index</controller>
					<action>area</action>
					<pages>
						<converta>
							<label>Convert</label>
							<controller>index</controller>
							<action>converta</action>
						</converta>
						<circle>
							<label>Circle</label>
							<controller>index</controller>
							<action>circle</action>
						</circle>
						<hexagon>
							<label>Hexagon</label>
							<controller>index</controller>
							<action>hexagon</action>
						</hexagon>
						<octagon>
							<label>Octagon</label>
							<controller>index</controller>
							<action>octagon</action>
						</octagon>
						<square>
							<label>Square</label>
							<controller>index</controller>
							<action>square</action>
						</square>
						<triangle>
							<label>Triangle</label>
							<controller>index</controller>
							<action>triangle</action>
						</triangle>
						<triangleeq>
							<label>Triangle (equilateral)</label>
							<controller>index</controller>
							<action>triangleeq</action>
						</triangleeq>
					</pages>
				</area>
				<length>
					<label>Length</label>
					<controller>index</controller>
					<action>length</action>
					<pages>
						<convertl>
							<label>Convert</label>
							<controller>index</controller>
							<action>convertl</action>
						</convertl>
					</pages>
				</length>
				<weight>
					<label>Weight</label>
					<controller>index</controller>
					<action>weight</action>
					<pages>
						<convertw>
							<label>Convert</label>
							<controller>index</controller>
							<action>convertw</action>
						</convertw>
					</pages>
				</weight>
			</pages>
		</measures>
		<calculators>
			<label>Calculators</label>
			<controller>index</controller>
			<action>calculators</action>
			<pages>
				<financial>
					<label>Financial</label>
					<controller>index</controller>
					<action>financial</action>
				</financial>
				<loanrep>
					<label>Loan repayments</label>
					<controller>index</controller>
					<action>loanrep</action>
				</loanrep>
			</pages>
		</calculators>
	</navigation>
</configuration>';    
    
    echo htmlentities($contents);  
    
    
?>
	</pre>
</div>
<div class="content">
<?php
    // commenting out to avoid showing exceptions as am not implementing controllers 
//    echo $this->layout()->content;
?>
</div>
</body>
</html>